package br.com.healthy.model.service;

import java.util.List;

import br.com.healthy.model.dao.AddressDao;
import br.com.healthy.model.dao.ContactDao;
import br.com.healthy.model.dao.PatientDao;
import br.com.healthy.model.entity.Contact;
import br.com.healthy.model.entity.Patient;

public class PatientService {

	PatientDao patientDao; 
	AddressDao addressDao;
	ContactDao contactDao;
	
	public PatientService(){
		
		patientDao = new PatientDao();
		addressDao = new AddressDao();
		contactDao = new ContactDao();
		
	}
	
	public void Insert(Patient patient){
		
		if (patient.getId() != 0){
			
			patientDao.Update(patient);
		}else {
			
			addressDao.Insert(patient.getAddress());
			contactDao.Insert(patient.getContact());
			patientDao.Insert(patient);
						
		}
	}
	
	public List<Patient> getAllPatient(){
		
		return patientDao.listAllPatient();
	}
	
}
